// encoding utf-8
#ifndef __QpwRenderItems__
#define __QpwRenderItems__

#include <QtCore/QMap>
#include <QpwGeometry.h>
#include <QpwStyle.h>
#include <QpwSubType.h>
#include <QyRenderAnimation.h>
#include <QyRenderItem.h>
#include <QyRenderItemGeometry.h>

namespace QpwItems {

class Decoration : public QyRender::Item {
public:
    enum ItemTypes {
        DecorationItemType = 0x100
    };

    explicit Decoration( QyRender::Layer * layer = 0 );
    virtual ~Decoration();

    virtual quint32 type() const { return DecorationItemType; }
    virtual QRectF boundingRect() const { return geometry().boundingRect(); }
    virtual QyRender::ItemGeometry geometry() const { return p_geometry; }
    quint32 currentAnimation() const { return p_currentAnimation; }
    QMap<quint32,QyRender::Animation> animations() const { return p_animations; }
    QColor color() const { return p_color; }
    QyGL::Texture * texture() const { return p_texture; }
    QPolygonF textureCoords() const { return p_textureCoords; }
    virtual QPointF pos() const;

    virtual void paint( const PaintMode & mode = DefaultPaint );
    virtual void move( const QPointF & pos );
    void setGeometry( const QyRender::ItemGeometry & geometry ) { p_geometry = geometry; }
    void setTextureCoords( const QPolygonF & textureCoords ) { p_textureCoords = textureCoords; }
    void setCurrentAnimation( quint32 currentAnimation ) { p_currentAnimation = currentAnimation; }
    void setAnimations( QMap<quint32,QyRender::Animation> animations ) { p_animations = animations; p_texture = 0; }
    void setColor( const QColor & color ) { p_color = color; }
    void setTexture( QyGL::Texture * texture ) { p_texture = texture; p_animations.clear(); }
    virtual void setSubType( const QpwSubType & subType );
    virtual void setStyle( const QpwStyle & style );
    virtual void setGeometry( const QpwWorld::Geometry & geometry );
    QyMath::Vector position;
    qreal rotation;
    QUuid uuid;

private:
    virtual QPolygonF buildTextureCoords() const;

    QyRender::ItemGeometry p_geometry;
    QMap<quint32,QyRender::Animation> p_animations;
    quint32 p_currentAnimation;
    QColor p_color;
    QyGL::Texture * p_texture;
    QPolygonF p_textureCoords;

};

};

#endif//__QpwRenderItems__
